#!/usr/bin/env bash
# error -- Show error message
#
# Author: Jaeho Shin <netj@ropas.snu.ac.kr>
# Created: 2010-07-28
before= after=
if [[ -t 2 ]] && ${MINDBENDER_COLOR:-true}; then
    # TODO check terminal's color support
    before=a; a() { echo -ne '\033[31m'; }
     after=b; b() { echo -ne '\033[0m'; }
fi

{
$before
for msg; do
    {
        [[ -z "$MINDBENDER_LOGERROR" ]] ||
            echo "$msg" >>"$MINDBENDER_LOGERROR"
    } 2>/dev/null
    echo "$msg"
done
$after
} >&2
false
